use std::ops::Range;
use rand::{rngs::StdRng, seq::{IndexedRandom, SliceRandom}, SeedableRng};

#[derive(Debug,Clone)]
pub struct RandomGen {
    vec: Vec<u8>,
    rng: StdRng,
}
impl RandomGen {
    pub(crate) fn new(range: Range<u8>) -> Self {
        let mut vec: Vec<u8> = range.collect();
        let mut rng = StdRng::from_os_rng();
        vec.shuffle(&mut rng);
        Self { vec: vec, rng: rng }
    }
    pub(crate)  fn get_random_num(&mut self)->Option<&u8>{
        self.vec.choose(&mut self.rng)
    }
}
